package day2;

import java.util.Scanner;

// java编程思想第4版
// Effective Java
public class HomeWork2 {
    public static void main(String[] args) {
        String sp1 = "百事可乐饮料1瓶";
        String sp2 = "百事500ml可乐1瓶";
        String sp3 = "5公斤面粉";
        String sp4 = "1个苏泊尔炒菜锅";
        String sp5 = "欧莱雅爽肤水一瓶";
        int price1 = 2;
        int price2 = 3;
        int price3 = 10;
        int price4 = 10;
        int price5 = 20;
        int condition1 = 50;
        int condition2 = 100;
        int condition3 = 100;
        int condition4 = 200;
        int condition5 = 200;
        // 消费总金额
        double total = 0;
        // 成功换购的商品
        String exchangeItem = null;
        // 是否换购
        boolean successExchange = false;
        Scanner input = new Scanner(System.in);
        System.out.print("请输入消费金额：");
        // 接收用户的消费金额
        double money = input.nextDouble();
        System.out.println("是否参加优惠换购活动:");
        // 选中要替换变量的常量，直接写2个双引号,在双引号中写2个+号,在2+号中写变量
        System.out.println("1: 满" + condition1 + "元，加" + price1 + "元换购" + sp1);
        System.out.println("2: 满" + condition2 + "元，加" + price2 + "元换购" + sp2);
        System.out.println("3: 满" + condition3 + "元，加" + price3 + "元换购" + sp3);
        System.out.println("4: 满" + condition4 + "元，加" + price4 + "元换购" + sp4);
        System.out.println("5: 满" + condition5 + "元，加" + price5 + "元换购" + sp5);
        System.out.println("0: 不换购");
        System.out.print("请选择：");
        byte choose = input.nextByte();
        switch (choose) {
            case 1:
                if(successExchange = money >= condition1) {
                    total = money + price1;
                    exchangeItem = sp1;
                }
                break;
            case 2:
                if(successExchange = money >= condition2) {
                    total = money + price2;
                    exchangeItem = sp2;
                }
                break;
            case 3:
                if(successExchange = money >= condition3) {
                    total = money + price3;
                    exchangeItem = sp3;
                }
                break;
            case 4:
                if(successExchange = money >= condition4) {
                    total = money + price4;
                    exchangeItem = sp4;
                }
                break;
            case 5:
                if(successExchange = money >= condition5) {
                    total = money + price5;
                    exchangeItem = sp5;
                }
                break;
        }
        if(!successExchange) {
            if(choose == 0) {
                System.out.println("不换购.谢谢光临!");
            } else {
                System.out.println("不符合换购条件！");
            }
        } else {
            System.out.println("本次消费总金额:" + total);
            System.out.println("成功换购:" + exchangeItem);
        }
    }
}
